using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace GardeningSkeleton.Platform.FXSpace
{
    public class AfterImageFx : MonoBehaviour
    {
        private SpriteRenderer sr;
        private float colorLooseRate;

        void Awake()
        {
            sr = GetComponent<SpriteRenderer>();
        }

        public void Setup(SpriteRenderer sr, float colorLooseRate)
        {
            this.sr.sprite = sr.sprite;
            this.colorLooseRate = colorLooseRate;
        }
        void Update()
        {
            sr.color = Color.Lerp(sr.color, Color.clear, colorLooseRate * Time.deltaTime);

            if(sr.color.a <= 0) 
                Destroy(gameObject);
        }
    }
}